/*
 *    Copyright (c) 2018-2025, boss All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the boss developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: boss
 */

package com.hopes.bizz.risk.control.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.hopes.bizz.risk.common.constant.RiskDicConstant;
import com.hopes.bizz.risk.common.constant.enums.RiskModDictEnum;
import com.hopes.bizz.risk.common.constant.enums.RiskSysDictEnum;
import com.hopes.boss.admin.api.resolver.DictResolver;
import com.hopes.boss.admin.api.resolver.enums.AdminDictEnum;
import com.hopes.boss.common.entity.BaseLogicEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;
import java.util.Optional;

/**
 * 隐患排查任务设置
 *
 * @author pig
 * @date 2023-07-20 09:01:45
 */
@Data
@TableName("risk_measure_task")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "隐患排查任务设置")
public class RiskMeasureTaskEntity extends BaseLogicEntity {

    private static final long serialVersionUID = 1L;


	/**
	* id
	*/
	@TableId(type = IdType.ASSIGN_ID)
    @Schema(description="id")
    private Long id;
	/**
	 * uid
	 */
	@Schema(description = "uid")
	private String uid;

	/**
	* 风险单元标识
	*/
    @Schema(description="风险单元标识")
    private Long riskUnitId;
	/**
	* 风险事件ID
	*/
    @Schema(description="风险事件ID")
    private Long riskEventId;

	/**
	* 管控措施ID
	*/
    @Schema(description="管控措施ID")
    private Long riskControlId;

	/**
	* 管控措施任务配置ID
	*/
    @Schema(description="管控措施任务配置ID")
    private Long riskTaskConfigId;

	/**
	* 隐患排查内容
	*/
    @Schema(description="隐患排查内容")
    private String checkContent;

	/**
	* 相关法规标准
	*/
    @Schema(description="相关法规标准")
    private String lawDesc;

	/**
	* 管控层级
	*/
    @Schema(description="管控层级")
    private Integer controlLevel;

	/**
	* 责任部门
	*/
    @Schema(description="责任部门")
    private String dept;

	/**
	* 岗位
	*/
    @Schema(description="岗位")
    private Long postId;

	/**
	* 责任人
	*/
    @Schema(description="责任人")
    private String responsibleUser;

	/**
	* 排查周期
	*/
    @Schema(description="排查周期")
    private Integer checkCycle;

	/**
	* 排查周期单位
	*/
    @Schema(description="排查周期单位")
    private String checkCycleType;

	/**
	* 工作开始时间
	*/
    @Schema(description="工作开始时间")
    private String workStartTime;

	/**
	* 工作结束时间
	*/
    @Schema(description="工作结束时间")
    private String workEndTime;

	/**
	* 工作日类型
	*/
    @Schema(description="工作日类型")
    private Integer workDayType;

	/**
	* 任务类型
	*/
    @Schema(description="任务类型")
    private Integer workType;

	/**
	* 包保任务对应项
	*/
    @Schema(description="包保任务对应项")
    private Integer taskNum;

	/**
	* 初始排查日期
	*/
    @Schema(description="初始排查日期")
    private Date startCheckDate;

	/**
	* 记录状态
	*/
    @Schema(description="记录状态")
    private Integer recordStatus;

	/**
	* 任务状态: 1 已启用 0 已停用
	*/
    @Schema(description="任务状态: 1 已启用 0 已停用")
    private Integer taskStatus;

	/**
	* 最近排查时间
	*/
    @Schema(description="最近排查时间")
	@TableField(updateStrategy = FieldStrategy.IGNORED)
    private Date latestCheckDate;

	/**
	* 排查结果: 正常：0；存在隐患:1；未排查：2；其他：3
	*/
    @Schema(description="排查结果: 正常：0；存在隐患:1；未排查：2；其他：3")
    private Integer checkStatus;

	/**
	* 备注
	*/
    @Schema(description="备注")
    private String remarks;

	/**
	* 机构ID
	*/
    @Schema(description="机构ID")
    private Long orgId;

    public String getRiskUnitIdStr() {
        return DictResolver.getItemLabelByValue(RiskModDictEnum.risk_unit, this.riskUnitId);
    }
    public String getRiskEventIdStr() {
        return DictResolver.getItemLabelByValue(RiskModDictEnum.risk_unit_event, this.riskEventId);
    }

    public String getPostIdStr() {
        return DictResolver.getItemLabelByValue(AdminDictEnum.sys_post, this.postId);
    }
    /* 排查周期单位 */
    public String getCheckCycleTypeStr() {
        return DictResolver.getItemLabelByValue(RiskSysDictEnum.check_cycle_type, this.checkCycleType);
    }
    /* 工作日类型 */
    public String getWorkDayTypeStr() {
        return DictResolver.getItemLabelByValue(RiskSysDictEnum.risk_work_day_type, this.workDayType);
    }
    /* 任务类型 */
    public String getWorkTypeStr() {
        return DictResolver.getItemLabelByValue(RiskSysDictEnum.risk_work_type, this.workType);
    }
    /* 包保任务对应项 */
    public String getTaskNumStr() {
		final Optional<Integer> optional = Optional.ofNullable(this.workType);
		if (optional.isPresent()) {
			if (optional.get().equals(RiskDicConstant.RISK_WORK_TYPE_1)) {
				return DictResolver.getItemLabelByValue(RiskSysDictEnum.risk_main_person, this.taskNum);
			} else if (optional.get().equals(RiskDicConstant.RISK_WORK_TYPE_2)) {
				return DictResolver.getItemLabelByValue(RiskSysDictEnum.risk_technology_person, this.taskNum);
			} else if (optional.get().equals(RiskDicConstant.RISK_WORK_TYPE_3)) {
				return DictResolver.getItemLabelByValue(RiskSysDictEnum.risk_operation_person, this.taskNum);
			}
		}
		return null;
    }
    /* 管控层级 */
	public String getControlLevelStr() {
		return DictResolver.getItemLabelByValue(RiskSysDictEnum.risk_control_level, this.controlLevel);
	}

	/* 任务状态 */
	public String getTaskStatusStr() {
		return DictResolver.getItemLabelByValue(RiskSysDictEnum.task_config_running_status, this.taskStatus);
	}
}
